// ********************************
// init.js Script
// ********************************

// * * * System Includes
EvaluateSystemScript("audio.js");
EvaluateSystemScript("screen.js");

// * * * Custom Includes
EvaluateScript("intro.js"); 
EvaluateScript("fademessage_jonboy.js"); 
EvaluateScript("jonboy_debug.js"); 
EvaluateScript("dialog.js"); 
EvaluateScript("jonboy_sprite.js"); 
EvaluateScript("kooparoids.js");

// * * * Global variables
var myLog;
var HEAD_HEIGHT = 64;
//var CONST_VIEW_WIDTH = 512;
//var CONST_VIEW_HEIGHT = 384;
var CONST_VIEW_WIDTH = 512+HEAD_HEIGHT;
var CONST_VIEW_HEIGHT = 384;
var BOARD_CENTER_X = CONST_VIEW_WIDTH/2;
var BOARD_CENTER_Y = HEAD_HEIGHT + (CONST_VIEW_HEIGHT/2);

/* function Delay(milliseconds)
{
  var start = GetTime();
  while (GetTime() - start < milliseconds);
} */

// FIRST FUNCTION called by game - put calls to init routines here!
function game(){
  NewGame();
}

function NewGame(){

  // Set up debug log
  jonboy_debug_begin(1);

/**/
  // Splash screen
  PlaySound("evillaugh.wav");
  IntroImage("KooparoidSplash02.png");
  
  // "BackStory"
  ShowIntroStory();
/**/  
  
  // Keep player from IMMEDIATELY escaping with ESC key
  BindKey(KEY_ESCAPE, 'ExitMapEngine()', 'DoNull()');
  
  // Do stuff
  KooparoidsPlay();  

  // Clean up and close out
  AuthorSplash();
  UnbindKey(KEY_ESCAPE);
  
}

